<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>分店管理-场地列表</title>
	<link rel="stylesheet" href="/js/plugin/layui-v2.3.0/layui/css/layui.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/index.css">
	<link rel="stylesheet" href="/css/project_set.css">
	<script src="/js/jquery-2.1.1.min.js"></script>
	<script src="/js/plugin/layui-v2.3.0/layui/layui.js"></script>
</head>
<style>
/* ::-webkit-scrollbar-thumb {
  background:rgb(95,106,135); 
  border-radius: 10px;
  height:50%;
} */
	body,html{
		height: auto; 
	}
</style>
<body>
	<div class="nav-section-content-container" style="padding: 0px">
		<header class="nav-header">
			<div class="nav-section-header-title">
				<span>场地管理</span>
				<div class="f-right">
				    <button class="layui-btn layui-btn-radius layui-btn-normal " id="add_field"><i class="layui-icon">&#xe654;</i>添加场地</button>
				    <button class="layui-btn layui-btn-radius layui-btn-normal " id="add_order"><i class="layui-icon">&#xe654;</i>添加新预约</button>
				</div>
			</div>
		</header>
		<div class="layui-tab layui-tab-brief my-tab" lay-filter="docDemoTabBrief">
			  <div class="layui-tab-content " style="padding: 0px">
					<div style='width: 100%; height: 100%; position: relative;'>
						<div class="nav-section-content-container clearfix" id="field_list">
							
							
						</div>
					</div>
			  </div>
		</div>
	</div>
</body>
<script>
var projectId=parent.parent.$("#projectId").val();
$(function(){
	setHeight()
	getFieldList();
	layui.use(['element','layer','form'], function(){
		var form = layui.form;
	})
	$("#add_field").on("click",function(){
		parent.parent.parent.layer.open({
			  type: 2, 
			  title:"创建场地",
			  area: ['700px','90%'],
		      shade: [0.6, '#010101'],
		      zIndex:800,
			  content:"/app/projectField/add/"+projectId , //这里content是一个普通的String
			  end: function () {
				  getFieldList();
		      }
		});
	})
	//添加新预约
    $("#add_order").on("click",function(){
    	$('#iframeSet-wrap', window.parent.document).children("iframe").attr('src','/app/projectFieldTeam/search');
    })
	$(".layui-tab-title li").on("click",function(){
		var type = $(this).attr("value");
		getFieldList();
	});
	
	
})
function tiaozhuan(id){
	
	var iframeSrc='/app/projectField/details/'+id+"_"+projectId;
	var iframe = document.createElement('iframe');//动态创建iframe，禁止iframe的src回退；
    iframe.src = iframeSrc;
    iframe.width = '100%';
    iframe.height = '100%';
    iframe.id = 'iframeSet';
    parent.$("#iframeSet-wrap").html($(iframe));
}
//封装获取数据
function getFieldList(){
　	var url="/app/projectField/listdata";
	jQuery.ajax({
        type:"post",
        async:false,
        url:url,
        dataType:"json",
        data:{'params[projectId]':projectId},
        success:function(data){
        	fieldList(data.data);
        }
    })
}
function fieldList(data){
	var cont="";
	for (var i = 0; i < data.length; i++) {
		var ioce="";
		var type="";
		var imgSrc="/images/meeting-room-default.png";
		if(data[i].type==1){
			type="会议室";
		}else if(data[i].type==2){
			type="休息区";
		}else if(data[i].type==3){
			type="咖啡店";
		}else if(data[i].type==4){
			type="健身房";
		}else if(data[i].type==5){
			type="活动区";
		}else if(data[i].type==6){
			type="演播室";
		}else if(data[i].type==7){
			type="摄影棚";
		}else if(data[i].type==8){
			type="游戏室";
		}else if(data[i].type==9){
			type="睡觉区";
		}else if(data[i].type==0){
			type="其他";
		}
		if(data[i].equipment!=null){
			if((data[i].equipment).indexOf(1)!=-1){
				ioce+='<span><i class="layui-icon layui-icon-layer"></i></span>';
			}
			if((data[i].equipment).indexOf(2)!=-1){
				ioce+='<span><i class="layui-icon layui-icon-chart-screen "></i></span>';
			}
			if((data[i].equipment).indexOf(3)!=-1){
				ioce+='<span><i class="layui-icon layui-icon-carousel"></i></span>';
			}
		}
		if(data[i].lock==1){
			ioce+='<span><i class=" layui-icon layui-icon-password"></i></span>';
		}
		if(data[i].attachment!=null){
			imgSrc=data[i].attachment.filePath+data[i].attachment.id+data[i].attachment.fileType;
		}
		cont+='<div class="meeting-room" onclick=tiaozhuan("'+data[i].id+'")>'
					+'<img src="'+imgSrc+'" alt="loading" height="150">'
				+'<div class="meeting-content">'
					+'<div class="d-iblock" style="margin-top: 10px;">'
						+'<span style="color: rgb(122, 81, 55); margin-right: 5px;">'+type+'</span>'
						+'<div style="display: inline-flex; align-items: center;">'
							+'<div class="color-nine">'
							+ioce
							+'</div>'
					+'</div>'
				+'</div>'
				+'<h4 class="meeting-room-name">'+data[i].name+'</h4>'
				+'<div class="meeting-people-num">容纳'+data[i].peopleNumber+'人</div>'
			+'</div>'
		+'</div>';
	}
	
	$("#field_list").html(cont);
	setHeight();
}

function setHeight(){
    var h = document.body.clientHeight;
    window.parent.setiframeWrap(h);
}
</script>
</html>